#include "autograd/graph_test.h"
#include "autograd/graph.h"


namespace  ldl
{
namespace autograd
{
void GraphTest::test()
{
    auto goldstein = [](Variable<float> x, Variable<float> y)->Variable<float> {
        auto z = (1.0f + (x + y + 1).square() * (19.0f - 14.0f*x + 3.0f*x.square() - 14.0f*y + 6.0f*x*y+3.0f*y.square())) * \
            (30.0f + (2.0f*x - 3.0f*y).square() * (18.0f - 32.0f*x + 12.0f*x.square() + 48.0f*y - 36.0f*x*y + 27.0f*y.square()));
        return z;
    };
    auto x = Variable<float>(1.0);
    auto y = Variable<float>(1.0);
    auto z = goldstein(x, y);
    z.backward();
    LogInfo() << "z: " << z;
    LogInfo() << "x.grad(): " << x.grad() << ", y.grad(): " << y.grad();

    // Graph::plot_dot_graph(z);
};
}
}